package de.mhus.lib.mandala.form;

import java.util.LinkedList;

public abstract class Select extends FormInput {

	protected LinkedList<Option> options = new LinkedList<Option>();
	
	public Select(String id, String caption, String ...valuecaption) {
		super(id, caption);
		if (valuecaption != null) {
			for (int i=0; i < valuecaption.length-1; i+=2) {
				if (valuecaption[i] != null && valuecaption[i+1] != null)
					add(valuecaption[i],valuecaption[i+1]);
			}
		}
	}

	public void clear() {
		options.clear();
	}
	
	public void add(String value, String caption) {
		add(new Option(value,caption));
	}
	
	public void add(Option option) {
		options.add(option);
	}
	
	public static class Option {
		private String value;
		private String caption;
		
		public Option(String value, String caption) {
			this.value = value;
			this.caption = caption;
		}
		
		public String getValue() {
			return value;
		}
		public void setValue(String value) {
			this.value = value;
		}
		public String getCaption() {
			return caption;
		}
		public void setCaption(String caption) {
			this.caption = caption;
		}
		
	}
	
}
